package com.example.myspringbootstarter;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration //表示该类为配置类
@ConditionalOnWebApplication // 当Spring为web服务时，才使注解的类生效；通常是配置类
@EnableConfigurationProperties(HelloProperties.class) //加载某个类的属性
public class HelloServiceAutoConfiguration {

    @Autowired
    HelloProperties helloProperties;


    @Bean
    public HelloService helloService(){
        HelloService service = new HelloService();
        service.setHelloProperties(helloProperties);
        return service;
    }

}
